home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************
- Source file: INCON.C
-
- This is the main input routine; it accepts keyboard entries from
- the user and builds an output string, which is copied to the i/o
- buffer passed from the caller. Internal support routines are
- declared below; external routines and data definitions are in
- the following files:
-
- INDEMO C Driver routine for testing and debugging.
- INALPHA C Alpha input handler.
- INFLOAT C Floating-point input handler.
- ININTGR C Integer input handler.
- INTEMPL C Template input handler.
- INUTIL C Public utility routines.
- INCON H State data used by INCON.
- INDECL H Prototypes and descriptions of utility routines.
- INDEFS H Definitions, constants, and macros.
- INSTATS H Header for Stat Box routine.
- STRINGZ ASM Public string manipulation routines.
- STRINGZ H Prototypes and descriptions for STRINGZ.ASM.
- STRINGZ OBJ Created from STRINGZ.ASM.
-
- Revision History
- ----------------
-
- Date Revision
- ----- -----------------------------------------------------
- 93/08 * Release version 2.0.
- * Extensive revision of v1.0;
- separate routines for handling each type of
- input field.
- * Floating-point fields no longer treated as
- templates.
- * Character matching handled by each input handler.
- * Added mixed template type.
- * [Backspace] now deletes the last character in
- templates and other fields where the cursor
- cannot move beyond that character.
- * Changed the fill character in template, float,
- and hidden fields to the Fill value passed in
- the message block, so that those fields display
- that character in vacant input slots.
- 94/05 * Release version 3.0.
- * Internal optimizations in handler routines.
- * Corrected bug in Numpad+ and Numpad- handling.
- * Added Stats() to print status of InCon flags
- and parameters after modification, if any,
- by initialization routines.
- * Added Debug flag to control display of Stats
- Box and run-time error messages.
- 94/08 * Release version 3.1.
- * Minor fixes to float field handling.
-
- Compiler: Borland Turbo C 2.01
-
- INCON source files and the object and library files created from
- them are:
- Copyright (c) 1993-94, Richard Zigler.
- You may freely distribute unmodified source, object, and library
- files, and incorporate them into your own non-commercial software,
- provided that this paragraph and the program name and copyright
- strings defined in INCON.C are included in all copies.
- *************************************************************************/
-
- #include <bios.h>
- #include <conio.h>
- #include <ctype.h>
- #include <dos.h>
- #include <stdlib.h>
- #include <string.h>
- #include "indefs.h"
- #include "incon.h"
- #include "indecl.h"
- #include "stringz.h"
-
- const char ProgName[] = "INCON 3.1 ";
- const char Copyright[] = "Copyright (c) 1993-94, Richard Zigler";
-
- short Chr ; /* keyboard character */
- short Col ; /* input field column */
- BFLAG EscSet ; /* [Esc] key pressed? */
- short FieldMin ; /* scrolling field first char */
- WORD Fill ; /* field fill character */
- BIT_FLAGS Flags ; /* message block flags word */
- BFLAG InBegin ; /* first input character? */
- BFLAG More ; /* get more input? */
- BFLAG Move ; /* move the cursor? */
- short Prec ; /* field min width/decimal chars */
- short Row ; /* input field row */
- short StrLength ; /* output string length */
- BFLAG Update ; /* update display? */
- short Width ; /* field max width */
- char * DisplayStr ; /* display string if Scroll; */
- /* template array if Template */
- char * InStr ; /* pointer to i/o buffer */
- /* passed from calling routine */
- char * OutStr ; /* build output string here; */
- /* OutStr copied to InStr if */
- /* input ok */
-
- /**** Module-wide Data ****/
-
- static WORD BufOff ; /* i/o buffer offset */
- static WORD BufSeg ; /* i/o buffer segment */
- static WORD FieldAttr ; /* input field video attributes */
- static short FieldMax ; /* scrolling field last char */
- static WORD KeyOff ; /* extended-key list offset */
- static WORD KeySeg ; /* extended-key list segment */
- static WORD NormAttr ; /* screen normal attribute */
- static WORD Pad ; /* output string pad character */
- static short Visible ; /* scrolling field display width */
- static char * xKeyList ; /* extended-key list passed */
- /* from calling routine */
-
- /**** Debug Status Declarations ****/
-
- #define INCON_STATS 1 /* 1 = enable/0 = disable stats */
- #if INCON_STATS
- #include "instats.h"
- #endif
-
- /**** Local Routines ****/
-
- static short pascal Error ( void );
- static void pascal FreeBuffers ( void );
- static int pascal Init ( MBLOCK far * );
- static void pascal Scroll ( int );
-
- /*************************************************************************
- InCon()
- *************************************************************************/
-
- short pascal InCon
- (
- MBLOCK far * BlockPtr /* pointer to message block */
- )
- {
- register int pos = 0 ; /* tracks cursor */
- register int work ; /* integer working storage */
- HANDLER p_handler = NULL ; /* ptr to input handling routine */
- STATES state = stInit; /* input state */
-
- /* extended character codes for edit keys used by InCon() */
-
- static char EditKeys[] =
- {
- HOME , /* move to start of input field */
- END , /* move to end of input field */
- LEFT , /* move left one character */
- RIGHT , /* move right one character */
- C_LEFT , /* move left one word */
- C_RIGHT , /* move right one word */
- DEL , /* delete character at cursor */
- C_L , /* delete word left */
- C_R , /* delete word right */
- C_END , /* delete to end of field */
- C_HOME , /* delete to start of field */
- K_PLUS , /* special exit or + */
- K_MINUS , /* special exit or - */
- 0
- };
-
- if ( !Init( BlockPtr ) ) /* init globals & environment */
- {
- *p_handler = Flags.Template ? hTemplateField :
- Flags.Type == FLOAT ? hFloatField :
- Flags.Type == INTGR ? hIntegerField :
- hAlphaField ;
-
- pos = p_handler( state, pos ); /* do type-specific init */
- }
- if ( (Chr = Error()) != 0 ) /* check for run-time errors */
- {
- textattr( NormAttr ); /* reset screen colors */
- return( Chr | 0x8000 ); /* turn on the high bit of Chr */
- }
-
- #if INCON_STATS
- if ( Flags.Debug )
- Stats( state, StatFlags ); /* init stats window */
- #endif
-
- /****
- Display delimiters if Delimit flag is set. The input field
- start column is incremented after placing the left delimiter.
- ****/
-
- if ( Flags.Delimit )
- {
- PutCursor( Row, Col++ );
- putch( L_DELIM );
- PutCursor( Row, Col + Visible );
- putch( FieldMax < StrLength ? R_CONT : R_DELIM );
- PutCursor( Row, Col );
- }
-
- /****
- Set up the input field. If the Template flag is set, fill the
- input field with spaces; otherwise, fill it with Fill. For
- non-scrolling fields, Visible is set equal to Width in Init().
- ****/
-
- WriteMany((Flags.Template ? (char) ' ' : (char) Fill), FieldAttr, Visible);
-
- /****
- Display default input string if one was passed in from caller.
- If the Scroll flag is set, display Visible characters from the
- left of OutStr; otherwise display the entire string.
- ****/
-
- if ( StrLength )
- cputs( Flags.Scroll ?
- (char *) LeftStr( DisplayStr, OutStr, Visible ) :
- OutStr );
-
- InBegin = More = YES; /* initialize flags */
- EscSet = NO;
-
- while ( KEYREADY ) /* clear keyboard buffer */
- KEYREAD;
-
- /****
- Get input until the field is filled, or until no more is required.
- This is the main loop, which is divided into four sections: the
- first handles edit and other extended keys; the second handles all
- other keys; the third calls the input handler routine and checks
- for automatic exit in unconfirmed fields; the fourth handles cursor
- moves and display string updates flagged by the input handler.
- ****/
-
- while ( More ) /**** start main loop ****/
- {
-
- /****
- Place cursor after field initialization and during subsequent
- activity in the field.
- ****/
-
- work = Col + pos - FieldMin;
- PutCursor( Row, work > MAXCOL ? MAXCOL : work );
-
- /****
- Update and Move monitor whether the user has edited the input
- string or merely moved the cursor. If the cursor moves left,
- Move is decremented; otherwise, it is incremented. If the
- input string has been modified, Update is incremented.
- ****/
-
- Move = Update = 0;
- state = stError;
- Chr = KEYREAD;
-
- if ( !LOBYTE(Chr) )
- { /**** extended keys ****/
- (WORD) Chr >>= 8;
-
- /* extended edit keys are disabled in hidden fields */
-
- if ( !Flags.Hide && strchr( EditKeys, Chr ) )
- {
- switch ( Chr )
- {
- case HOME : state = stMoveToStart ; break ;
- case END : state = stMoveToEnd ; break ;
- case LEFT : state = stMoveCharLeft ; break ;
- case RIGHT : state = stMoveCharRight ; break ;
- case C_LEFT : state = stMoveWordLeft ; break ;
- case C_RIGHT : state = stMoveWordRight ; break ;
- case C_HOME : state = stDeleteToStart ; break ;
- case C_END : state = stDeleteToEnd ; break ;
- case DEL : state = stDeleteAtCursor ; break ;
- }
- }
- else
- {
-
- #if INCON_STATS /* display Stat Box if enabled */
- if ( Chr == NUM5 && Flags.Debug )
- {
- Stats( state, StatFlags );
- continue;
- }
- #endif
-
- __Extended: /* check caller's extended list */
- ;
- if ( Flags.xKeys && strchr( xKeyList, Chr ) )
- More = NO;
- else
- ERROR_BEEP;
- continue; /* with while(More) */
- }
- } /**** extended keys ****/
- else
- { /**** ASCII keys ****/
- work = (WORD) Chr >> 8;
- if ( work == K_PLUS ) /* [Numpad +] and [Numpad -] */
- { /* are treated as special exit */
- Chr = work; /* keys in numeric fields */
- state = stExitPlus;
- }
- else if ( work == K_MINUS )
- {
- Chr = work;
- state = stExitMinus;
- }
- else
- {
- switch ( Chr &= 0xFF )
- {
- case TAB : goto __Extended ;
- case BS : state = stDeleteCharLeft ; break ;
- case CR : state = stQuit ; break ;
- case C_L : state = stDeleteWordLeft ; break ;
- case C_R : state = stDeleteWordRight ; break ;
- case ESC : state = stFieldClear ; break ;
- default : state = stCharMatch ; break ;
- }
- }
- } /**** ASCII keys ****/
- pos = p_handler( state, pos );
- EscSet = (state == stFieldClear); /* set EscSet to YES or NO */
-
- /****
- Most cursor moves are handled by the cursor update at the
- top of the while() loop. Scrolling fields, though, impose
- additional conditions.
- ****/
-
- if ( Move )
- {
- if ( Flags.Scroll && (pos <= FieldMin || pos >= FieldMax) )
- Scroll( pos );
- }
-
- /****
- The last entry caused a change in the output string. If the
- Scroll flag is set, call Scroll() to update the displayed
- substring regardless of whether or not the cursor has moved
- out of the visible field. Otherwise, if this is not a hidden
- field (or if a hidden field has been cleared with [Esc]),
- display the new input string and fix the field mask.
- ****/
-
- else if ( Update )
- {
- if ( Flags.Scroll )
- Scroll( pos );
- else if ( !Flags.Hide || state == stFieldClear )
- {
- PutCursor( Row, Col );
- cputs( OutStr );
- }
- } /* else if (Update) */
- if ( More )
- {
- if ( !Flags.Confirm && Update ) /* check for automatic exit */
- { /* except on cursor keys */
- More = Chr = Flags.Template ?
- strchr( OutStr, Fill ) ? -1 : 0 :
- StrLength < Width ? -1 : 0 ;
- if ( !More )
- {
- if ( Flags.Template && Flags.Strip )
- p_handler( stQuit, pos ); /* strip template */
- goto __Beep; /* signal auto exit */
- }
- }
- if ( !(Move || Update) ) /* if last key caused neither */
- { /* exit, move, nor update, */
- __Beep:
- ;
- ERROR_BEEP; /* key is illegal */
- continue; /* with while (More) */
- }
- else
- InBegin = NO;
- }
-
- /****
- If the input string only partly fills the field, mask the
- remainder of the field with Fill characters if input is to
- continue; otherwise, clear any left-over mask from the field.
- ****/
-
- work = StrLength - FieldMin;
- if ( work < Visible )
- {
- PutCursor( Row, Col + work );
- WriteMany( More ? (char)Fill : ' ', FieldAttr, Visible - work );
- }
- } /**** while (More) ****/
-
- if ( Chr == 0 || Chr == K_PLUS || Chr == K_MINUS ) /* if input ok */
- {
- switch( Flags.Justify )
- {
- case NJUST : /* no justify */
- strcpy( InStr, OutStr );
- break;
- case LJUST : /* left justify */
- lJust( InStr, OutStr, Width, (char) Pad );
- break;
- case CJUST : /* center string */
- cJust( InStr, OutStr, Width, (char)Pad );
- break;
- case RJUST : /* right justify */
- rJust( InStr, OutStr, Width, (char)Pad );
- break;
- }
- }
- textattr( NormAttr ); /* reset colors */
- PutCursor( Row, (Flags.Delimit ? --Col : Col) ); /* and cursor */
-
- FreeBuffers();
- while ( KEYREADY ) /* clear keyboard buffer */
- KEYREAD;
- return( Chr ); /* error extended code */
- } /**** InCon() ****/
-
- /*************************************************************************
- Error()
- Check parameters passed in message block for errors.
- *************************************************************************/
-
- #define ERRP ". Press any key..."
-
- enum ErrCodes
- {
- FieldPrec = 1,
- FieldWidth ,
- DefString ,
- FloatPrec ,
- FloatDecimal ,
- FillTemplate ,
- BadTemplate ,
- NoMemory ,
- NullBuffer ,
- } ;
-
- static short pascal Error( void )
- {
- register int err_code = 0; /* run-time error code */
- static char * err_str[] =
- {
- "\a INCON error" ,
- "Invalid field precision" ,
- "Invalid field width or scroll visible length" ,
- "Default input string too long" ,
- "Type float; precision is invalid" ,
- "Type float; no room for decimal point" ,
- "Fill character appears in template" ,
- "Invalid template" ,
- "Insufficient memory for internal buffers" ,
- "Input/output buffer pointer is NULL" ,
- };
-
- if ( Prec > Width )
- err_code = FieldPrec;
-
- /****
- Visible is used here to determine whether a Width error has occurred
- because Visible will be equal to Width for non-scrolling fields, and
- Visible characters must fit on the screen line for scrolling fields.
- ****/
-
- else if (Visible <= 0 || (Col + Visible + (Flags.Delimit ? 2 : 0)) > MAXCOL)
- err_code = FieldWidth;
- else if ( StrLength > Width )
- err_code = DefString;
- else if ( Flags.Type == FLOAT && Prec <= 0 )
- err_code = FloatPrec;
- else if ( Flags.Type == FLOAT && (Width - Prec - 1) < 0 )
- err_code = FloatDecimal;
- else if ( Flags.Template && strchr( InStr, LOBYTE(Fill) ) )
- err_code = FillTemplate;
- else if ( Flags.Template && *OutStr == '\0' )
- err_code = BadTemplate;
- else if
- (
- OutStr == NULL
- ||
- (DisplayStr == NULL && (Flags.Scroll || Flags.Template))
- #if INCON_STATS
- ||
- (Flags.Debug && (SaveScreen == NULL || SaveStats == NULL))
- #endif
- )
- err_code = NoMemory;
- else if ( InStr == NULL )
- err_code = NullBuffer;
-
- /* Release buffers and print run-time error message. */
-
- if ( err_code )
- {
- FreeBuffers();
- if ( Flags.Message ) /* if messaging enabled */
- {
- PutCursor( Row, 0 );
- WriteMany( ' ', FieldAttr, MAXCOL );
- cprintf
- (
- "%s %d: %s%s",
- *err_str, err_code, *(err_str + err_code), ERRP
- );
- KEYREAD; /* wait for keypress */
- cputs( "\r\n" );
- }
- }
- return( err_code );
- } /**** Error() ****/
-
- /*************************************************************************
- FreeBuffers()
- Free allocated memory.
- *************************************************************************/
-
- static void pascal FreeBuffers( void )
- {
-
- #if INCON_STATS
- if ( SaveStats != NULL )
- free( SaveStats );
- if ( SaveScreen != NULL )
- free( SaveScreen );
- #endif
-
- if ( DisplayStr != NULL )
- free( DisplayStr );
- if ( OutStr != NULL )
- free( OutStr );
- }
-
- /*************************************************************************
- Init()
- This routine transfers the message block contents to internal
- variables and sets up the overall environment for InCon(). Some
- error trapping is done here, as well. All memory allocation is
- localized to this routine.
- *************************************************************************/
-
- static int pascal Init
- (
- MBLOCK far * BlockPtr /* message block pointer */
- )
- {
- static WORD init = 0; /* flag first time through */
-
- GetCursor( &Row, &Col );
-
- BufOff = BlockPtr->sblock.BufOff;
- BufSeg = BlockPtr->sblock.BufSeg;
- KeyOff = BlockPtr->sblock.KeyOff;
- KeySeg = BlockPtr->sblock.KeySeg;
- Flags = BlockPtr->sblock.Flags.bflags;
- Width = BlockPtr->sblock.Width;
- Prec = BlockPtr->sblock.Prec;
- Visible = BlockPtr->sblock.Visible;
- FieldAttr = BlockPtr->sblock.Attr;
- Fill = BlockPtr->sblock.Fill;
- Pad = BlockPtr->sblock.Pad;
-
- InStr = (char *) MK_FP( BufSeg, BufOff ); /* default input */
- xKeyList = (char *) MK_FP( KeySeg, KeyOff ); /* extended-key list */
-
- OutStr = DisplayStr = NULL; /* initialize buffer pointers */
-
- #if INCON_STATS
- SaveScreen = SaveStats = NULL;
- #endif
-
- if ( !init )
- {
- ++init;
- NormAttr = GetVideoAttr();
- delay( 0 );
- }
- if ( !FieldAttr )
- FieldAttr = ((NormAttr & 0x07) << 4) | /* reverse current */
- ((NormAttr & 0x70) >> 4) | /* attribute */
- ( NormAttr & 0x08) ; /* preserve intense */
-
- /* if back/fore still the same, toggle intensity */
-
- if ( ((FieldAttr & 0x70) >> 4) == (FieldAttr & 0x0F) )
- FieldAttr ^= 0x08;
-
- textattr( FieldAttr );
-
- if ( Fill < ' ' ) /* Fill and Pad default to */
- Fill = ' '; /* ASCII space */
- if ( Pad < ' ' )
- Pad = ' ';
-
- if ( Flags.Debug ) /* if Debug flag is set, */
- Flags.Message = YES; /* enable error messages */
-
- if ( xKeyList == NULL || !*xKeyList ) /* xKeyList invalid */
- Flags.xKeys = NO;
-
- if ( Flags.Type == FLOAT ) /* float fields are not */
- Flags.Template = NO; /* templates */
-
- if ( !Flags.Template && (Flags.Type & INTGR) )
- {
- Flags.Hide = /* turn off Hide and Scroll in */
- Flags.Scroll = NO; /* non-template numeric fields */
- lTrim( InStr, InStr ); /* strip leading and trailing */
- rTrim( InStr, InStr ); /* spaces and control codes */
- }
-
- StrLength = strlen( InStr );
- if ( Width <= 0 ) /* attempt to remedy if invalid */
- Width = StrLength; /* if fails, Error() aborts */
-
- /* if i/o buffer null or allocation fails, return immediately to InCon */
-
- if ( (char *) InStr )
- {
- if ( Width && (OutStr = calloc( Width + 1, sizeof(char) )) != NULL )
- {
- if ( StrLength )
- LeftStr( OutStr, InStr, Width ); /* don't allow overflow */
-
- if ( Flags.Hide ) /* disable scrolling for */
- Flags.Scroll = NO; /* hidden input fields */
-
- if (
- !Flags.Template
- &&
- Flags.Type == INTGR
- &&
- strchr( OutStr, '.' )
- )
- {
- Flags.Type = FLOAT; /* force signed float input if */
- Flags.Sign = YES; /* '.' in non-template integer */
- }
-
- if ( Flags.Template ) /* input template */
- {
- Flags.Justify = NJUST; /* no justification/scrolling */
- Flags.Scroll = NO;
- if ( Width > StrLength ) /* hold width/prec to length */
- Width = StrLength; /* of template */
- Prec = Width;
- if ( Flags.Type >= INTGR ) /* use [Numpad +/-] to indicate */
- Flags.Sign = NO; /* signed input */
- DisplayStr = malloc( Width + 1 ); /* type flags */
- }
- else if
- (
- ((Col + Width) > MAXCOL) /* field longer than screen line */
- &&
- (Flags.Type < INTGR) /* field is alpha/upper */
- &&
- !Flags.Scroll /* non-scrolling */
- &&
- !Flags.Hide /* Error() aborts if hidden */
- ) /* or non-alpha field */
- {
- Flags.Scroll = YES; /* force scrolling */
- Flags.Delimit = NO; /* turn off delimiters */
- Visible = MAXCOL - Col; /* visible out to end of line */
- }
-
- /****
- Initialize scroll variables. FieldMin and FieldMax
- index the visible range of characters in OutStr as
- the user edits the string or moves through it with
- the cursor keys. Initially, FieldMin is zero for
- all types of fields and FieldMax is set to Visible
- for scrolling fields, so that Visible characters
- are displayed from the left end of the default string.
- For non-scrolling fields, FieldMax and Visible both are
- set to Width, which allows for simplification of some
- statements in the handler routines; the same indexing
- can be applied to scrolling and non-scrolling fields.
- ****/
-
- if ( Flags.Scroll )
- DisplayStr = malloc( Visible + 1 );
- else
- Visible = Width;
-
- FieldMin = 0;
- FieldMax = Visible;
-
- /****
- If Debug flag is set, allocate buffers for saving screen
- contents of window and of data under window.
- ****/
-
- #if INCON_STATS
- if ( Flags.Debug )
- {
- SaveScreen = malloc( SaveSize );
- SaveStats = malloc( SaveSize );
- }
- #endif
- } /* if (OutStr) */
- } /* if (InStr ) */
-
- return ( InStr == (char *) 0 || OutStr == (char *) 0 );
- } /**** Init() ****/
-
- /*************************************************************************
- Scroll()
- This routine handles scrolling input fields. FieldMin and FieldMax
- index the beginning and end of the visible part of OutStr. They form
- a sliding "window", which is Visible characters wide, into the entire
- input string. This routine is called to update the display whenever
- OutStr has been changed by the user, and whenever the cursor has been
- moved outside the bounds of the visible field.
- *************************************************************************/
-
- static void pascal Scroll
- (
- register int Pos /* position in input string */
- )
- {
-
- /****
- If the cursor is at or below the left boundary of the field,
- set the new left boundary one character to the left of the
- cursor or to the beginning of the input string, whichever
- is greater. That keeps the character to the left of the
- cursor visible, so that "delete left" is not done blind.
- ****/
-
- if ( Pos <= FieldMin )
- {
- FieldMin = Pos > 0 ? Pos - 1 : Pos ;
- FieldMax = FieldMin + Visible;
- }
-
- /****
- If the cursor is at or above the right boundary of the field,
- set the new right boundary at the cursor position. FieldMax
- is a 1-based index rather than a 0-based pointer, so it is
- set to one more than the cursor position.
- ****/
-
- else if ( Pos >= FieldMax )
- {
- FieldMax = Pos >= Width ? Pos : Pos + 1 ;
- FieldMin = FieldMax - Visible;
- }
-
- if ( Flags.Delimit ) /* display delimiters */
- {
- PutCursor( Row, Col - 1 );
- putch( FieldMin > 0 ? L_CONT : L_DELIM );
- PutCursor( Row, Col + Visible );
- putch( FieldMax < StrLength ? R_CONT : R_DELIM );
- }
-
- /****
- Display Visible characters of the output string, beginning at
- FieldMin. The string functions expect a 1-based index into
- the source string, so FieldMin is incremented before it is
- passed to MidStr(). All of the string functions return a
- pointer to the null-terminated target string (first parameter),
- which is a substring of the source string (second parameter).
- ****/
-
- PutCursor( Row, Col );
- cputs( (char *) MidStr( DisplayStr, OutStr, FieldMin + 1, Visible ) );
-
- } /**** Scroll() ****/
-
- #if INCON_STATS
-
- /*************************************************************************
- Stats()
- Displays parameters after field initialization. This routine is
- compiled only if the constant INCON_STATS is non-zero.
- *************************************************************************/
-
- static void pascal Stats( STATES State, WORD * Flags )
- {
- register int bit,
- ndx;
- int x1,
- x2,
- y1,
- y2;
-
- gettextinfo( &TextInfo ); /* save caller's window stats */
- x1 = TextInfo.winleft;
- x2 = TextInfo.winright;
- y1 = TextInfo.wintop;
- y2 = TextInfo.winbottom;
-
- /**** Display Window Layout
-
- Field___________________
- Input___________________
- ________________________
- ________________________
- ________________________
- ╔════════════════════════════════════════════════════════════════════════════╗
- ║ INCON 3.1 Copyright (c) 1993-94, Richard Zigler ║
- ║ ioBuf segment:offset = XXXX:XXXX xKeyList segment:offset = XXXX:XXXX ║
- ║ Width: XX Prec: XX Visible: XX Attr: XX Fill: XX Pad: XX ║
- ║ Flags: B BBB BB B B B B B B B B B B Use [Numpad 5] to toggle Stat Box ║
- ╚════════════════════════════════════════════════════════════════════════════╝
-
- ****/
-
- if ( State == stInit ) /* if initializing */
- {
- Cursor( SAVE );
- Cursor( OFF );
- gettext( STAT_WINDOW, SaveScreen ); /* save screen contents */
-
- for ( bit = 0x8000, ndx = 0 ; StatsMask[ndx] ; ndx++ )
- {
- if ( StatsMask[ndx] == 'B' )
- {
- StatsBuf[ndx] = *Flags & bit ? '1' : '0' ;
- (WORD) bit >>= 1;
- }
- else
- StatsBuf[ndx] = '\x20';
- }
- StatsBuf[ndx] = '\0';
-
- window( STAT_WINDOW ); /* set stat window */
- clrscr();
- cprintf /* print modified parms */
- (
- " ╔══════════════════════════════════════"
- "══════════════════════════════════════╗ "
- " ║ %-37s%s ║ "
- " ║ ioBuf segment:offset = %.4X:%.4X"
- " xKeyList segment:offset = %.4X:%.4X ║ "
- " ║ Width: %.2X Prec: %.2X Visible: %.2X"
- " Attr: %.2X Fill: %.2X Pad: %.2X ║ "
- " ║ Flags: %-33sUse [Numpad 5] to toggle Stat Box ║ "
- " ╚══════════════════════════════════════"
- "══════════════════════════════════════╝"
- , ProgName, Copyright
- , BufSeg, BufOff
- , KeySeg, KeyOff
- , Width, Prec
- , Visible, FieldAttr
- , Fill, Pad
- , StatsBuf
- );
-
- gettext( STAT_WINDOW, SaveStats ); /* save stat block */
- window( x1, y1, x2, y2 ); /* restore window */
- Cursor( RESTORE ); /* and cursor */
- Cursor( ON );
- }
- else
- {
- puttext( STAT_WINDOW, SaveStats ); /* display stat block */
- while ( KEYREAD != (NUM5 << 8) ) /* wait for [Numpad 5] */
- ERROR_BEEP;
- }
- puttext( STAT_WINDOW, SaveScreen ); /* restore screen */
- } /**** Stats() ****/
-
- #endif
-
- /**** EOF: INCON.C ****/